<?php
include "../../Koneksi/koneksi.php";

$kodeMapel = $_POST['kodeMapel'];

$namaMapel = $_POST['namaMapel'];


$cek = mysql_fetch_array(mysql_query("SELECT kodeMapel FROM mataPelajaran WHERE kodeMapel='$kodeMapel'"));
if (empty($cek['kodeMapel'])) {
    mysql_query("insert into mataPelajaran (kodeMapel, namaMapel, semester) value "
            . "('$kodeMapel' ,'$namaMapel' ,"
            . "1)");
    $result = header('location:../Form/FormMataPelajaran.php');
} else {
    ?>
    <script>alert("Kode Mapel Sudah Ada");
                    document.location.href = "../Form/FormMataPelajaran.php"</script>
    <?php
}

echo $result;
?>